import React, { Component } from 'react'

export default class App extends Component {
  constructor() {
    super();
    this.state = {
      name: "React",
      isLinked: false
    }
  }
  handleBtnClick = () => {
    this.setState({
      isLinked: !this.state.isLinked
    })
  }
  render() {
    return (
      <div>
        <h1>欢迎来到React开发</h1>
        <button onClick={
          () => {
            this.handleBtnClick()
          }
        }>{this.state.isLinked ? "收藏" : "取消收藏"}</button>
      </div>
    )
  }
}
